package com.jyy.prefabricated.controller;

import com.jyy.prefabricated.common.AjaxResult;
import com.jyy.prefabricated.dto.CourseCategoryExamDto;
import com.jyy.prefabricated.entity.CourseCategoryExam;
import com.jyy.prefabricated.entity.CourseWithBLOBs;
import com.jyy.prefabricated.service.CourseCategoryExamService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * 课程包分类考试表(CourseCategoryExam)表控制层
 *
 * @author mrl
 * @since 2021-10-14 19:53:21
 */
@Slf4j
@RequestMapping("/api")
@RestController
public class CourseCategoryExamController {
    /**
     * 服务对象
     */
    @Resource
    private CourseCategoryExamService courseCategoryExamService;


    /**
     * 新增课程包分类考试应达学时规则
     * @param courseCategoryExamDto
     * @return
     */
    @PostMapping("/courseCategoryExam")
    public AjaxResult insert(@Valid @RequestBody CourseCategoryExamDto courseCategoryExamDto) throws Exception {
        log.info("Rest request to insert course:{}",courseCategoryExamDto);

        int result = courseCategoryExamService.insertCourseCategoryExam(courseCategoryExamDto);
        return AjaxResult.success(result);
    }
    @GetMapping("/courseCategoryExam")
    public AjaxResult selectCourseCategoryExam(CourseCategoryExam courseCategoryExam) {
        List<CourseCategoryExam> courseCategoryExams = this.courseCategoryExamService.queryAll(courseCategoryExam);
        return AjaxResult.success(courseCategoryExams);
    }
}